<template>
  <div>
    <dv-scroll-board :config="config" class="table" style="height:39vh" />
  </div>
</template>

<script>
// import moment from 'moment'
import {getEquipProgressApi} from '../../../api/product/index.js'
export default {
  name: '',
  data() {
    return {
      config: {
        header: ['设备','设备状态', '模具', '派工数','报工数量','合格数','报废数','合格率','达成率' ],
        headerHeight: 20,
        data: [],
        index: false,
        columnWidth: [140, 120, 240,100,100,100,100,100,100],
        align: ['left'],
        headerBGC: ' ',
        oddRowBGC: ' ',
        evenRowBGC: 'rgba(52,99,171,0.15)',
        waitTime: '5000',
        rowNum: 10,
      },
      dataList: [],
    }
  },
  props: {
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      const _that = this
      getEquipProgressApi({pkCorp: 1002}).then(res => {
        const {code,data} = res
        if(code === 2000) {
          _that.dataList = data
          const mConfig = {..._that.config}
          mConfig['data'] = []
          data.forEach(mData => {
            const m = []
            m.push(mData.equipName)
            let c = ''
            switch(mData.state) {
              case '0':
              case 0:
                c = `<label style="background:#ffba00;padding:3px 4px; border-radius: 20px;font-weight: 700;">停</label>`
                break;
              case '1':
              case 1:
                c = `<label style="background:#13ce66;padding:3px 4px; border-radius: 20px;font-weight: 700;">停</label>`
                break
              case '2':
              case 2:
                c = `<label style="background:#ff4d4f;padding:3px 4px; border-radius: 20px;font-weight: 700;">修</label>`
                break
            }
            m.push(c)
            m.push(mData.moldName)


            m.push(mData.sumDispatchQty)
            m.push(mData.sumReportQty)
            m.push(mData.sumQualifiedQty)
            m.push(mData.sumScrapQty)
            // m.push(mData.heGeLv + '%')


            if(Number(mData.heGeLv) >= 80) {
              m.push(`<label style="color:#13ce66;font-size: 18px">${mData.heGeLv}%</label>`)
            }else if(Number(mData.heGeLv) >= 60) {
              m.push(`<label style="color:#1890ff;font-size: 18px">${mData.heGeLv}%</label>`)
            }else {
              m.push(`<label style="color:#ff4d4f;font-size: 18px">${mData.heGeLv}%</label>`)

            }

            if(Number(mData.daChengLv) >= 80) {
              m.push(`<label style="color:#13ce66;font-size: 18px">${mData.daChengLv}%</label>`)
            }else if(Number(mData.daChengLv) >= 60) {
              m.push(`<label style="color:#1890ff;font-size: 18px">${mData.daChengLv}%</label>`)
            }else {
              m.push(`<label style="color:#ff4d4f;font-size: 18px">${mData.daChengLv}%</label>`)

            }
            mConfig.data.push(m)
          });
          _that.config = mConfig
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
.table {
  .px2vw(padding-left, 10);
  .px2vw(padding-right, 10);
}
/deep/ .row-item{
    height: 28px !important;
    line-height: 28px !important;
}
</style>
